<?php
// No direct access to this file
defined('_JEXEC') or die;
 
// import the list field type
jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('groupedlist');

 
/**
 * NGMenu Form Field class for the NGMenu component
 */
class JFormFieldFontValues extends JFormFieldGroupedList
{
	/**
	 * The field type.
	 *
	 * @var		string
	 */
	protected $type = 'FontValues';
 
	/**
	 * Method to get the field option groups.
	 *
	 * @return	array	The field option objects as a nested array in groups.
	 * @since	1.6
	 */
	protected function getGroups() {
		
		$groups = array();
		
		$groups['Common Fonts'][] = JHtml::_('select.option', 'arial,helvetica,sans-serif', 'Arial, Helvetica, sans-serif' );
		$groups['Common Fonts'][] = JHtml::_('select.option', 'times new roman,times,serif', 'Times New Roman, Times, serif' );
		$groups['Common Fonts'][] = JHtml::_('select.option', 'courier new,courier,verdana,sans-serif', 'Courier New, Courier, Verdana, sans-serif' );
		$groups['Common Fonts'][] = JHtml::_('select.option', 'georgia,times new roman,times,serif', 'Georgia, Times New Roman, Times, serif' );
		$groups['Common Fonts'][] = JHtml::_('select.option', 'verdana,arial,helvetica,sans-serif', 'Verdana, Arial, Helvetica, sans-serif' );
		$groups['Common Fonts'][] = JHtml::_('select.option', 'tahoma,verdana,arial', 'Tahoma, Verdana, Arial' );
		$groups['Common Fonts'][] = JHtml::_('select.option', 'geneva,arial,helvetica,sans-serif', 'Geneva, Arial, Helvetica, sans-serif' );
		$groups['Common Fonts'][] = JHtml::_('select.option', 'book antiqua,times new roman', 'Book Antiqua, Times New Roman' );
		$groups['Common Fonts'][] = JHtml::_('select.option', 'century gothic,tahoma,arial,helvetica,sans-serif', 'Century Gothic, Tahoma, Arial, Helvetica, Sans-Serif' );
		
		$database =& JFactory::getDBO();
		$query = $database->getQuery(true);
		$query->select('*');
		$query->from('#__ngmenu_fonts');
		$query->order(array('subset','name'));
		$database->setQuery($query);
		$database->query();
		if($database->getNumRows()){
			$rows = $database->loadAssocList();
			foreach($rows as $row){
				$groups['Google Web Fonts ('.$row['subset'].')'][] = JHtml::_('select.option', $row['css_name'].'|'.$row['subset'], $row['name'].' ('.$row['subset'].')');
			}
		}
		return $groups;
	}
}
